home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr25 / pmenv.zip / DLGSUP.C next >
C/C++ Source or Header  |  1993-03-01  |  4KB  |  88 lines

  1. #define INCL_WINFRAMEMGR
  2. #define INCL_WINMENUS
  3. #define INCL_WINMESSAGEMGR
  4. #define INCL_WINSYS
  5. #include <os2.h>
  6.  
  7. #include "dlgsup.h"
  8.  
  9.  
  10. /*********************************************************************/
  11. /*                                                                   */
  12. /*  FUNCTION : CenterDlgBox                                          */
  13. /*                                                                   */
  14. /*  Positions the dialog box in the center of the screen             */
  15. /*                                                                   */
  16. /*********************************************************************/
  17.  
  18. VOID CenterDlgBox( HWND hwnd )
  19. {
  20.   SHORT ix, iy;
  21.   SHORT iwidth, idepth;
  22.   SWP   swp;
  23.  
  24.   /* Query width and depth of screen device                          */
  25.   iwidth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN );
  26.   idepth = (SHORT)WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN );
  27.  
  28.   /* Query width and depth of dialog box                             */
  29.   WinQueryWindowPos( hwnd, (PSWP)&swp );
  30.  
  31.   /* Center dialog box within the screen                             */
  32.   ix = ( iwidth  - swp.cx ) / 2;
  33.   iy = ( idepth  - swp.cy ) / 2;
  34.   WinSetWindowPos( hwnd, HWND_TOP, ix, iy, 0, 0, SWP_MOVE );
  35. }
  36.  
  37.  
  38.  
  39.  
  40. /*********************************************************************/
  41. /*                                                                   */
  42. /* FUNCTION: SetSystemMenu                                           */
  43. /*                                                                   */
  44. /* Edit items in the system menu to leave "Move", "Close", and       */
  45. /* "Switch to Task Manager".                                         */
  46. /*                                                                   */
  47. /*********************************************************************/
  48. VOID SetSystemMenu( HWND hwndDlg )
  49. {
  50.   HWND     hwndSysMenu;                 /* sys menu pull-down handle */
  51.   MENUITEM miTemp;                      /* menu item template        */
  52.   SHORT    sItemId;                     /* system menu item ID       */
  53.   SHORT    sItemIndex;                  /* system menu item index    */
  54.  
  55.   /*******************************************************************/
  56.   /* Get the handle of the system menu pull-down.                    */
  57.   /*******************************************************************/
  58.   hwndSysMenu = WinWindowFromID( hwndDlg, FID_SYSMENU );
  59.   WinSendMsg( hwndSysMenu,
  60.               MM_QUERYITEM,
  61.               MPFROM2SHORT( SC_SYSMENU, FALSE ),
  62.               MPFROMP( (PSZ)&miTemp ));
  63.   hwndSysMenu = miTemp.hwndSubMenu;
  64.  
  65.   /*******************************************************************/
  66.   /* Remove all items from the system menu pull-down that are no     */
  67.   /* longer wanted.                                                  */
  68.   /*******************************************************************/
  69.   for ( sItemIndex = 0, sItemId = 0; sItemId != MIT_ERROR; sItemIndex++)
  70.   {
  71.     sItemId = SHORT1FROMMR (WinSendMsg( hwndSysMenu,
  72.                                  MM_ITEMIDFROMPOSITION,
  73.                                  MPFROMSHORT( sItemIndex ),
  74.                 (MPARAM) 0 ));
  75.     if ( sItemId != MIT_ERROR &&
  76.          sItemId != SC_MOVE   &&
  77.          sItemId != SC_CLOSE  &&
  78.          sItemId != SC_TASKMANAGER )
  79.     {
  80.       WinSendMsg( hwndSysMenu,
  81.                   MM_DELETEITEM,
  82.                   MPFROM2SHORT( sItemId, FALSE ),
  83.                  (MPARAM)NULL );
  84.       sItemIndex--;
  85.     }
  86.   }
  87. }
  88.